const http = require('http');

const server = http.createServer((request, response) => {
    
    const url = request.url;
    const urlObj = new URL(url, 'http://localhost:8080');

    // response.writeHead(200, {
    //     'content-type': 'application/text'
    // })
    switch (urlObj.pathname) {
        case '/data':
            response.write(`${urlObj.searchParams.get('cb')}('${url}')`);
            break; 
    
        default:
            response.write('page nofound');
            break;
    }
    response.end();
})

server.listen(8080, () => {
    console.log('localhost:8080');
})